package com.yricky.fakenote;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.app.usage.UsageStats;
import android.app.usage.UsageStatsManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.view.WindowManager;
import android.widget.Toast;

import java.util.List;

public class MainActivity extends Activity {
    private Intent gsIntent;
    private SharedPreferences sp;
    private boolean showToast;
    private boolean debugMode;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        gsIntent=new Intent(MainActivity.this,GhostService.class);
        sp= getSharedPreferences("sp",MODE_PRIVATE);

        showToast = sp.getBoolean("toast",true);
    }

    @Override
    protected void onResume() {
        super.onResume();
        if(sp.getBoolean("firstlaunch1.1",true)){
            sp.edit().putBoolean("firstlaunch1.1",false).commit();
            Intent nfIntent = new Intent(this,HelpActivity.class);
            startActivity(nfIntent);
        }else {
            WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
            if(showToast)
                Toast.makeText(this,R.string.service_start,Toast.LENGTH_SHORT).show();
            startForegroundService(gsIntent);
            layoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        stopService(gsIntent);
        if(showToast)
            Toast.makeText(this,R.string.service_stop,Toast.LENGTH_SHORT).show();
        finish();
    }
}